package com.wlstock.funi.utils;


import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharePreferenceUtils {
	private final static String SPF_NAME = "com.wlstock.funi";
	

		
	public static Boolean getBoolSP(Context mContext, String key,Boolean defaultValue){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		return spf.getBoolean(key, defaultValue);
	} 
	
	public static void setBoolSP(Context mContext, String key, boolean value){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		Editor edit = spf.edit();
		edit.putBoolean(key, value);
		edit.commit();
	}
	
	public static void setIntSP(Context mContext,String key,int value){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		Editor edit = spf.edit();
		edit.putInt(key, value);
		edit.commit();
	}
	
	public static int getIntSP(Context mContext,String key,int defaultValue){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		return spf.getInt(key, defaultValue);
	}
	
	public static float getFloatSP(Context mContext,String key,float defaultValue){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		return spf.getFloat(key, defaultValue);
	}
	
	public static void setFloatSP(Context mContext,String key, float value){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		Editor edit = spf.edit();
		edit.putFloat(key, value);
		edit.commit();
	}

	public static String getStringSP(Context mContext,String key,String defaultValue){
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		return spf.getString(key,defaultValue);
	}

	public static void setStringSP(Context mContext,String key, String value){
		if (value==null) value="(null)";
		SharedPreferences spf = mContext.getSharedPreferences(SPF_NAME, Context.MODE_APPEND);
		Editor edit = spf.edit();
		edit.putString(key, value);
		edit.commit();
	}
	
}
